package com.example.handle.global;

import com.example.exception.global.CustomerException;
import com.example.pojo.vo.global.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/9/21 15:40
 */
@RestControllerAdvice(basePackages = {"com.example.controller"})
@Slf4j
public class GlobalExceptionJsonHandler {

    /**
     * Json 形式返回
     * @param e
     * @return
     */

    @ExceptionHandler(CustomerException.class)
    public Result<?> handleRRException(CustomerException e){
        log.error(e.getMessage(), e);
        return Result.error(e.getMessage());
    }
}
